public class Solution1185 {
    public String dayOfTheWeek(int day, int month, int year) {
        String[] ans=new String[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
        int[] months=new int[]{0,3,3,6,1,4,6,2,5,0,3,5};
        int t=(year-1967+(year-1969)/4)%7;
        t=(t+months[month-1])%7;
        if (year%4==0 && year!=2100 && month>=3){
            t=(t+1)%7;
        }
        return ans[(t+day)%7];
    }

    public static void main(String[] args) {
        System.out.println(new Solution1185().dayOfTheWeek(31,8,2019));
    }
}
